package com.xand.bt.terminal.common.util;

import java.io.BufferedInputStream;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;

public class NetHelper {

	public static String fetchUrlAsString(String webUrl) {

		String ret;
		
		StringBuilder sb = new StringBuilder();

		try {
			
			String line;
			
			URL url = new URL(webUrl);
			InputStream is = url.openStream();  // throws an IOException
			DataInputStream dis = new DataInputStream(new BufferedInputStream(is));

			while ((line = dis.readLine()) != null) {
				sb.append(line);
			}
			is.close();
			
			ret = sb.toString();
			
		}catch(IOException e){
			ret = null;
		}

		return ret;

	}
	
}
